<template>
  <div>
      <div class="cart">
            <div  @click="topay(index)"  v-for=" item,index  in moneyList" :key="item.id" class="item">
                <div v-show="item.hot" class="po">
                      <svg-icon class="hot" iconClass="hot"></svg-icon>
                </div>    
              <div class="num">
                    <span> {{ item.num }} </span>  <span> COINS</span></div>
                  <div class="bonus"> + {{ item.bonus }} BONUS</div>
                  <div class="price"> USD $ {{ item.price }}</div>
            </div>
      </div>

      <van-popup class="pay" v-model:show="payshow" round  position="bottom"
      safe-area-inset-bottom style="transition: all 0.3s;">
      <payicon  :options="moneyList[selected]"></payicon>
    </van-popup>
  </div>
</template>

<script>
import { getpayoptions } from '@/api/home';
import payicon from '@com/payicon/payicon.vue'

export default {
  data(){
    return {
      payshow:false,
      selected:0,
         moneyList:[
          { id: 1 , num:600,price:"5.99"  , bonus:30  ,hot:false},
          { id: 2 , num:1000,price:"9.99",bonus:300,hot:true},
          { id: 3 , num:1500,price:"14.99",bonus:525,hot:false},
          { id: 4 , num:2500,price:"24.99",bonus:1250,hot:false},
          { id: 5 , num:4000,price:"39.99",bonus:2400,hot:false},
          { id: 6 , num:5000,price:"49.99",bonus:3500,hot:true},
        ]
    }
  },
 async created(){
        let result  = await getpayoptions()
        console.log('result',result);
        this.moneyList = result
  },
  methods:{
    topay(i){
      this.selected =i 
      this.payshow= true
    }
  }
};
</script>

<style lang="scss" scoped>
.cart{
  padding: 1rem 0.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: 0.5rem ;
  .item{
    position: relative;
    background-color: #fff;
    border-radius: 0.5rem;
    box-shadow: 0px 0px 0.2rem  #f0e9e9;
    padding: 0.2rem 0 0 0 ;
    .num{
      font-weight: 600;
      padding-left: 0.5rem;
      color: black;
    }
    .num span:nth-child(1){
      font-size: 0.8rem;
    }
    .num span:nth-child(2){
      font-size: 0.5rem;
    }
    .svg-icon{
      position: absolute;
      color: red;
      top: 0px;
      left: 0.1rem;
      font-size: 0.5rem;
    }
    .bonus{
      font-size: 0.4rem;
      color: #ccc;
      margin:  0.2rem 0;
      padding-left: 0.5rem;
    }
    .price{
      border-top: 0.5px solid #ccc;
      font-size: 0.7rem;
      padding: 0.1rem 0;
      text-align: center;
      color: #2409ed;
      line-height: 1rem;
     
    }
  }
  .po{
    width: 0.7rem;
    height: 0.6rem;
    background-color:#ef2506 ;
    position: absolute;
    top: 0.5rem;
    right: 0;
    border-bottom-left-radius: 50%;
    border-top-left-radius: 50%;
    }
}
</style>
